<?php

/**
 * 获取全部的自定义url以及系统模块的url管理logic
 */

namespace Member\Logic;

class MurlUrlLogic extends CommonLogic {

	/**
	 * 获取全部的系统模块Url和普通的url
	 */
	public function MurlUrl(){
		
		//获取全部的模块信息
		$moudleurlLogic = D('MoudleUrl','Logic');
		$moudleurls = $moudleurl->allLists();
		
		$moudles = array();
		//对模块url进行分组
		foreach ($moudleurls as $v){
			//是首页地址
		    if($v['index']){
		        $moudles['index'][] = $v;
		        continue;
		    }
		    //二级页面
		    $moudles['others'][$v['moudle']][] = $v;
		}
		
		
		//获取全部的图文消息
		$urlsLogic = D('Urls','Logic');
		$urls = $urlsLogic->allLists();
		
		$data = array(
		    'moduleurls'=>$moudles,
			'urls'=>$urls,
		);
		return $data;
	}
	
	/**
	 * 根据选择的信息返回需要保存到数据库中的信息
	 */
	public function savedata($name){
		$newsmsgLogic = D('Newsmsg','Logic');
		//如果是单图文消息内容
		if(intval($name) > 0){
			$newmsg = $newsmsgLogic->detail(intval($name));
			 
		}else{
			//如果是模块内容信息
			$newmsg = $newsmsgLogic->where(array('relation'=>$name,'uid'=>UID))->find();
		}
		$data = array(
		    'msgtype'=>$newmsg['msgtype'],
		    'msgid'=>$newmsg['id'],
		);
		
		return $data;
			
	}
	/* (non-PHPdoc)
	 * @see \Member\Logic\CommonLogic::autoSave()
	 */
	public function autoSave($id = 0) {
		// TODO Auto-generated method stub
		
	}

	/* (non-PHPdoc)
	 * @see \Member\Logic\CommonLogic::update()
	 */
	public function update($id = 0) {
		// TODO Auto-generated method stub
		
	}

	
	
}